#! python3
# Adds Wikipedia bullet points to the start
# of each line of text on the clipboard.

# pyperclip 是一个 Python 模块，用于跨平台地复制和粘贴文本到剪贴板。
# 这意味着你可以使用它在 Python 脚本中将文本发送到剪贴板，然后在任何其他应用程序中粘贴该文本，反之亦然。
# pyperclip 支持 Windows、MacOS 和 Linux 等主流操作系统。

import pyperclip

# Get text from clipboard. (从剪贴板读取文本)
text = pyperclip.paste()

# Separate lines and add stars.
lines = text.split('\n')
for i in range(len(lines)):     # loop through all indexes for "lines" list
    lines[i] = '* ' + lines[i]  # add star to each string in "lines" list
text = '\n'.join(lines)
pyperclip.copy(text)
print(text)

text_to_copy = "Hello, world!"
pyperclip.copy(text_to_copy)            # Copy the text to the clipboard.
text_from_clipboard = pyperclip.paste() # Get the text from the clipboard.
print(text_from_clipboard)              # Print the text from the clipboard.